import request from '@/utils/request'

const pre = '/fmea/common/function'

// 获取功能详情
export function getFunctionInfo(id) {
  return request({
    url: `${pre}/` + id,
    method: 'get'
  })
}

// 获取功能关系树
export function getRelationTree(data) {
  return request({
    url: `${pre}/getRelationTree`,
    method: 'get',
    params: data
  })
}

export function saveRelation(data) {
  return request({
    url: `${pre}/saveRelation`,
    method: 'get',
    params: data
  })
}

export function disRelation(data) {
  return request({
    url: `${pre}/deleteRelation`,
    method: 'get',
    params: data
  })
}

export function download(query) {
  return request({
    url: `${pre}/exportTemplate`,
    method: 'get',
    params: query
  })
}

export function getTtFunctionList(data) {
  return request({
    url: `${pre}/getTtFunctionListByPid`,
    method: 'get',
    params: data
  })
}

export function getDFeatureList(data) {
  return request({
    url: `${pre}/getDFeatureListVoByPid`,
    method: 'get',
    params: data
  })
}

export function batchFunc(data) {
  return request({
    url: `${pre}`,
    method: 'post',
    data: data
  })
}

export function checkExist(data) {
  return request({
    url: `${pre}/check`,
    method: 'get',
    params: data
  })
}

export function deleteFunction(obj) {
  return request({
    url: `${pre}/` + obj.id,
    method: 'delete',
    params: obj.data
  })
}

export function editFunc(data) {
  return request({
    url: `${pre}`,
    method: 'put',
    data: data
  })
}

// 根据项目id查询特性矩阵
export function getFeatureMatrix(query) {
  return request({
    url: '/fmea/common/function/getFeatureMatrixByPid',
    method: 'get',
    params: query
  })
}

// 获取dfmea矩阵图
export function getDFeatureMatrix(query) {
  return request({
    url: 'fmea/common/function/getDFeatureMatrixBySid',
    method: 'get',
    params: query
  })
}

// 导出特殊特性矩阵
export function exportFeatureMatrixTemplate(query) {
  return request({
    url: '/fmea/common/function/exportFeatureMatrixTemplate',
    method: 'get',
    params: query
  })
}

// 导出DFMEA的特性矩阵
export function exportDFeatureMatrixTemplate(query) {
  return request({
    url: '/fmea/common/function/exportDFeatureMatrixTemplate',
    method: 'get',
    params: query
  })
}

// 导出特性清单
export function exportFeatureList(query) {
  return request({
    url: '/fmea/common/function/exportFeatureList',
    method: 'get',
    params: query
  })
}
